<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <main id="app">
        <p>全名：{{fullName}}</p>
        <p>性别：{{sex}}</p>
        <button @click="sayHello">点我</button>
    </main>
</body>
<script src="../vue.min.js"></script>
<script>
    // 定义一个对象，用作混入对象。它的属性和构建vue对象的属性一样。
    let mymix = {
        el: "#app",
        data() {
            return {
                age: 35,
                sex: "女",
            }
        },
        methods: {
            sayHello() {
                console.log("Hello:",this.fullName);
            }
        },
        computed: {
            fullName() {
                return this.firstName + " " + this.lastName;
            }
        }
    }

    let vue = new Vue({
        // 混入（可以混入多个对象，于是用数组）
        mixins: [mymix],
        data() {
            return {
                firstName: "Hydra",
                lastName: "Feng",
                sex: "男",
            }
        }
    })

    console.log(vue.$data);

</script>
</html>